﻿Imports System.Collections.Generic
Imports System.Linq
Imports System.Text
Imports ApplicationBoomVB.Command

Namespace ViewModel
    Class MainWindow
        Inherits Base.BaseObject

        Public Sub New()
            m_AsyncSimulationTimer = New Timers.Timer(15)
            AddHandler m_AsyncSimulationTimer.Elapsed, Sub(s, e)
                                                           m_Index += 1
                                                           Children.Add(New DataModel.SimpleDataObject() With {.Text = "Text", .Index = m_Index, .Description = .Text})

                                                       End Sub
        End Sub
        Private m_AsyncSimulationTimer As Timers.Timer
        Private m_Index As Long

        Public Property TextObject() As DataModel.SimpleDataObject
            Get
                If m_TextObject Is Nothing Then
                    m_TextObject = New DataModel.SimpleDataObject()
                End If
                Return m_TextObject
            End Get
            Set(value As DataModel.SimpleDataObject)
                m_TextObject = value
                OnPropertyChanged("TextObject")
            End Set
        End Property
        Private m_TextObject As DataModel.SimpleDataObject

        Public ReadOnly Property Children() As System.Collections.ObjectModel.ObservableCollection(Of DataModel.SimpleDataObject)
            Get
                If m_Children Is Nothing Then
                    m_Children = New System.Collections.ObjectModel.ObservableCollection(Of DataModel.SimpleDataObject)()
                    AddHandler m_Children.CollectionChanged, Sub(s, e)
                                                                 OnPropertyChanged("Children")
                                                             End Sub
                End If
                Return m_Children
            End Get
        End Property
        Private m_Children As System.Collections.ObjectModel.ObservableCollection(Of DataModel.SimpleDataObject)



        Public ReadOnly Property StartTimerCommand As RelayCommand
            Get
                If m_StartTimerCommand Is Nothing Then
                    m_StartTimerCommand = New RelayCommand(Sub(param) m_AsyncSimulationTimer.Start())
                End If
                Return m_StartTimerCommand
            End Get
        End Property
        Private m_StartTimerCommand As RelayCommand

     

        Public ReadOnly Property StopTimerCommand As RelayCommand
            Get
                If m_StopTimerCommand Is Nothing Then
                    m_StopTimerCommand = New RelayCommand(Sub(param) m_AsyncSimulationTimer.Stop())
                End If
                Return m_StopTimerCommand
            End Get
        End Property
        Private m_StopTimerCommand As RelayCommand
    End Class
End Namespace